package com.example.demo.designpattern.strategy.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.example.demo.designpattern.strategy.context.TestMethodContext;
import com.example.demo.designpattern.strategy.enums.TestMethod;
import com.example.demo.designpattern.strategy.service.TestMethodService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Api(tags = "2 测试测试")
@RestController
@RequestMapping("/m")
public class TestMethodController {

    @ApiOperation(value = "测试接口a")
    @GetMapping("/a")
    public String methodA(@RequestParam String name){
        TestMethod tm = null;
        switch (name){
            case "a": tm = TestMethod.AF;break;
            case "b": tm = TestMethod.BF;break;
            case "c": tm = TestMethod.CF;break;
        }
        TestMethodService handler = TestMethodContext.getHandler(tm);
        handler.sendRequest(name);
        return "OK";
    }
}
